package com.example.demo.util;

import cn.hutool.core.lang.Console;
import org.junit.Test;

import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;

/**
 * Description: nio测试<br/>
 *
 * @author liulonglong<br               />;
 * @taskId <br/>
 * @Date 2019/7/24 9:44
 * @Version 1.0
 */
public class NIOTest {

    /**
     * 创建文件或者目录D:\ProgramFile\workspace_dev\demo\liu
     */
    @Test
    public void test1() {
        Path path = Paths.get("liu");
        Console.log(path.toAbsolutePath());
        boolean exists = Files.notExists(path);
        if (exists) {
            try {
                Files.createDirectories(path);
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        Path txt = path.resolve("1.txt");
        if (Files.notExists(txt)) {
            try {
                Files.createFile(txt);
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        File file = txt.toFile();
    }

    @Test
    public void test2() {

    }

}
